package com.jmpt.fangbohui.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.jmpt.fangbohui.R;
import com.jmpt.fangbohui.ui.base.BaseHeadFragment;
import com.jmpt.fangbohui.utils.ToastHelper;

public class MainInfoFragment extends BaseHeadFragment implements OnClickListener {

	private View rootView;

	public MainInfoFragment() {
		// Required empty public constructor
	}

	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		//确保不会重复添加
		if (rootView != null) {
			ViewGroup parent = (ViewGroup) rootView.getParent();
			if (parent != null) {
				parent.removeView(rootView);
			}
			//返回原有的布局对象  不往下走了
			return rootView;
		}
		super.onCreateView(inflater, container, savedInstanceState);
		rootView = inflater.inflate(R.layout.fragment_info, container, false);
		rootView = setContentView(rootView);
		
		//这里开始初始化布局中的控件
		assignViews(rootView);
		showTitle("资讯");
		//显示右上角按钮
		showHeadRightButton("更多", this);
		
        initView();
        
		return rootView;
	}
	//查找界面控件
	private void assignViews(View rootView2) {
		// TODO Auto-generated method stub
		
	}
	/**
	 * 初始化空间
	 */
	private void initView() {
		// TODO Auto-generated method stub
		
//		addMenuItem(R.drawable.btn_main_home,"主页");
//		addMenuItem(R.drawable.btn_main_home,"搜索");
//		addMenuItem(R.drawable.btn_main_home,"搜索");
//		addMenuItem(R.drawable.btn_main_home,"搜索");
//		addMenuItem(R.drawable.btn_main_home,"搜索");
		
	}

	private boolean showMenu = false;
	@Override
	public void onClick(View v) {
		if(showMenu){
			closeMenu();
		}else{
			showMenu();
		}
		showMenu = !showMenu;
	}
	
	@Override
	protected void onMenuSelected(int index,String lable) {
		ToastHelper.ShowToast("index : "+index + "lable : " + lable,getActivity());
	}
}
